<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<?php
/**
 * Created by PhpStorm.
 * User: dapeng
 * Date: 2018/9/27
 * Time: 下午4:05
 */


//增加用户
//1、获取页面上填写的值($_POST(更安全)|$_GET)
$name = $_POST["name"];
$no = $_POST["no"];
$tel = $_POST["tel"];
$birth_date=$_POST["date"];
$birth_place=$_POST["address"];
$text=$_POST["text"];
//2、连接数据库
try{
    $pdo = new PDO("mysql:host=127.0.0.1;dbname=tt","root","");
}catch (Exception $e){
    var_dump($e);
    die("连接失败");
}

//3、组装插入语句
$insertSQL = "UPDATE tt_stud SET stud_name='{$name}',stud_tel={$tel},
birth_date={$birth_date},birth_place={$birth_place},`text`='{$text}' WHERE stud_id = {$no};";//


echo $insertSQL."<br>";
//4、执行插入语句
//$res = $pdo->query($insertSQL);//普遍用于查询,返回的是一组结果集
$res = $pdo -> exec($insertSQL);//普遍用户增删改,返回结果是一个整型,1 2


//5、判断是否注册成功,进入到用户列表页面中。
if ($res > 0){
//    echo "注册成功<a href='userlist.php'>走你</a>";


    echo "<meta http-equiv=\"refresh\" content=\"1; url=index.php?a=Student&f=userlist&page=1\">";
    print('更新成功,正在拼命的跳转页面...<br>1秒后自动跳转~~~');

}else{
    echo "更新失败";
    var_dump($pdo->errorInfo());
}




